from sqlalchemy import Column, Integer, String, Float, ForeignKey, Date
from sqlalchemy.orm import relationship

from day20.database.database import Base


class Score(Base):
    __tablename__ = "score"

    id = Column(Integer, primary_key=True, autoincrement=True, comment="自增序号")
    stu_id = Column(Integer, ForeignKey("stu.stu_id", ondelete="CASCADE"), comment="学生编号")
    stu_name = Column(String(20), nullable=True, comment="学生姓名(冗余)")
    class_name = Column(String(20), nullable=True, comment="学生班级(冗余)")
    assessment_sequence = Column(Integer, nullable=False, comment="考核序次")
    mark = Column(Integer, nullable=True, comment="分数")

    to_stu = relationship("Stu", back_populates="stu2score")